transcode: fix destructive assignment after drain
authorAlaric Senat <alaric@videolabs.io>
Mon, 24 Jun 2024 16:11:23 +0000 (18:11 +0200)
committerSebastian Ramacher <sramacher@debian.org>
Fri, 7 Mar 2025 06:31:22 +0000 (07:31 +0100)
commitd301a7550a698017ae67fa132aaf021029cec387
tree5e6dd32917917cd7355b7c4b7e71018566bdae68
parentddc833a8f4b4d27f6c7e65cdc9422efd9224c538
transcode: fix destructive assignment after drain

The drain checks are done after the first encoder output fetch. At this
point, `out` is already filled with some frames gotten from the encoder
some lines above:

```
// ...
    if( p_sys->i_threads >= 1 )
    {
        /* Pick up any return data the encoder thread wants to output. */
        vlc_mutex_lock( &p_sys->lock_out );
        *out = p_sys->p_buffers;
        p_sys->p_buffers = NULL;
        vlc_mutex_unlock( &p_sys->lock_out );
    }

// ...
```

This assignment currently leaks all previously gathered frames to
replace them by the drained output. This patch appends the drained
frames to the existing output instead.

Gbp-Pq: Name 0008-transcode-fix-destructive-assignment-after-drain.patch
modules/stream_out/transcode/video.c